﻿/*
This project and all of its code is/are Copyright (C) 2017  Nils Hunter Alving

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/
using System;

namespace DynamicDependencyContainer.Interfaces
{
    /// <summary>
    /// Specifies methods used to resolved dependencies
    /// </summary>
    public interface IResolveDependencies
    {
        /// <summary>
        /// Returns an instance of the type that was registered to represent the specified interface. How it will be resolved 
        /// is determined by how it was originally registered
        /// </summary>
        /// <typeparam name="T">An interface that was previously registered</typeparam>
        /// <returns>An object that implements the interface</returns>
        T Resolve<T>() where T : class;
        /// <summary>
        /// Returns an instance of the type that was registered to represent the specified interface. How it will be resolved 
        /// is determined by how it was originally registered. Instance will be passed to the initializer function before it is returned
        /// </summary>
        /// <typeparam name="T">An interface that was previously registered</typeparam>
        /// <param name="initializerFunction">A function that accepts the instance as a parameter. Use this function to intialize properties on the instance</param>
        /// <returns>An initialized instance of T</returns>
        T Resolve<T>(Action<T> initializerFunction) where T : class;
        /// <summary>
        /// Returns an instance of the type that was registered to represent the specified interface. How it will be resolved 
        /// is determined by how it was originally registered
        /// </summary>
        /// <param name="type">The type of the interface to be resolved</param>
        /// <returns>An object that implements the interface</returns>
        object Resolve(Type type);
        /// <summary>
        /// Returns an instance of the type that was registered to represent the specified interface. How it will be resolved 
        /// is determined by how it was originally registered. Instance will be passed to the initializer function before it is returned
        /// </summary>
        /// <param name="type">The type of the interface to be resolved</param>
        /// <param name="initializerFunction">A function that accepts the instance as a parameter. Use this function to intialize properties on the instance</param>
        /// <returns>An initialized instance of the specified type</returns>
        object Resolve(Type type, Action<object> initializerFunction);
    }
}
